import logging

from redis import StrictRedis


class Config(object):
    # 设置session
    SECRET_KEY = "bVeYC6jsz7khdBVTEi7ms6AkHFofcIWGUTAWEja1gqHCNnwCiN1ONapJETkYu3wx"

    # MYSQL
    # 数据库的配置信息
    SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:wenhao123@localhost:3306/information'
    # 关闭追踪数据库的修改
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 数据库自动提交
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    # REDIS
    # redis服务器ip
    REDIS_HOST = "localhost"
    REDIS_PORT = "6379"
    REDIS_PASSWORD = "wenhao"

    # False-session配置
    SESSION_TYPE = 'redis'
    # 给session配置redis的操作对象
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    # 给session加密签名处理
    SESSION_USE_SIGNER = True
    # 设置session可以过期
    SESSION_PERMANENT = False
    # 设置session有效期
    PERMANENT_SESSION_LIFETIME = 86400 * 2  # 单位是秒 这里 是2天
    # 设置log记录等级
    LOGIN_LEVEL = logging.DEBUG


class DevelopementConfig(Config):
    """开发模式"""
    DEBUG = True
    LOGIN_LEVEL = logging.DEBUG


class ProductionConfig(Config):
    """生产模式"""
    pass


config = {
    "Devel": DevelopementConfig,
    "Produ": ProductionConfig
}
